package com.zy.qudadid.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.User;
import com.zy.qudadid.presenter.MyWalletPresenter;
import com.zy.qudadid.ui.activity.base.ToolBarActivity;
import com.zy.qudadid.ui.view.MyWalletView;
import com.zy.qudadid.utils.AESCrypt;
import com.zy.qudadid.utils.StringUtil;
import com.zy.qudadid.utils.UserUtil;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyWalletActivity extends ToolBarActivity<MyWalletPresenter> implements MyWalletView {

    @Bind(R.id.txtMoney)
    TextView txtMoney;
    @Bind(R.id.rlQuan)
    RelativeLayout rlQuan;

    @Override
    protected CharSequence provideTitle() {
        return "我的钱包";
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_my_wallet;
    }

    @Override
    public void initListeners() {

    }

    @Override
    protected void initThings(Bundle savedInstanceState) {
        super.initThings(savedInstanceState);

//        rlQuan.setVisibility(View.GONE);

        Map<String,String> map = new HashMap<>();
        map.put("user_id",new UserUtil(getContext()).getUserId());
//        map.put("type","1");
        String json = StringUtil.toJson(map);
        try {
            String data1 = AESCrypt.getInstance().encrypt(json);
            String d = StringUtil.replaceBlank(data1);
            presenter.getInfo(d);
        } catch (Exception ex) {
        }
    }

    @Override
    public MyWalletPresenter createPresenter() {
        return new MyWalletPresenter();
    }

    @OnClick(R.id.rlQuan)
    public void onClick() {
        startActivity(MyCouponActivity.class);
    }

    @Override
    public void getInfoSuccess() {
        txtMoney.setText(new UserUtil(getContext()).getUser().account);
    }

    @Override
    public void getInfoError(String str) {

    }
}
